<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="include/base.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <style type="text/css">
    	#nav2{
    		margin: 40px auto;
    	}
    	.input{
    		height: 25px;
    	}
    </style>
  </head>
  <body>
    <%@ include file="include/top.jsp"%>
    <ul id="nav2" class="breadcrumb">
	  <li><a href="goodsin"><img src="<%=basePath %>static/img/gi.png"/></a></li>
	  <li><a href="goodsBack"><img src="<%=basePath %>static/img/gb.png"/></a></li>
	</ul>
    <div class="container">
   		<form class="form-horizontal" action = "addGoodsBack" method="post">
			    <div class="control-group">
					<a style="margin-left: 80px">退货票号：</a>
					<input type="text" id="backId" class="input" name="id">
					<a style="margin-left: 100px">退货时间：</a>
					<input type="text" id="backTime" class="input" name="time">
				</div>
				<div class="control-group">
					<a style="margin-left: 80px">供应商名：</a>
					<input type="text" id="backprovider" class="input" name="provider.id">
					<a style="margin-left: 100px">商品编号：</a>
					<input type="text" id="goodsbackId" class="input" name="goods.id">
				</div>
				<div class="control-group">
					<a style="margin-left: 80px">操作人员：</a>
					<input type="text" id="backope" class="input" name="operator.id">
					<a style="margin-left: 100px">退货数量： </a>
					<input type="text" class="input" name="outputnum">
					
				</div>
				<div class="control-group">
					<a style="margin-left: 80px">支付类型：</a>
					<select id="multiSelect" name="paytype" style="width: 209px">
						<option></option>
						<option>现金</option>
						<option>银行卡</option>
						<option>支票</option>
					</select>
					<a style="margin-left: 100px">退货原因：</a>
					<input type="text" class="input" name="reason">
					<a id="btnback" class="btn btn-primary" href="javascript:void(0)" style="margin-left: 50px"><i class="icon-plus-sign icon-white"></i>添加</a>
					<button class="btn btn-danger" type="submit"><i class="icon-arrow-left icon-white"></i>退货</button>
				</div>
	    </form>
	    <hr/>
	    <table class="table table-bordered" style="border-width: 2px">
			<thead>
				<tr>
					<th>请选择商品</th>
					<th>商品编号</th>
					<th>商品名称</th>
					<th>产地</th>
					<th>规格</th>
					<th>包装</th>
					<th>价格</th>
					<th>数量</th>
					<th>生产批号</th>
					<th>供应商</th>
			  	</tr>
		 	</thead>
		 	<tbody>
		 		<c:forEach items="${inventoryList}" var="inventory">
			 		<tr>
			 			<td><a id="check" href="#" rel="${inventory.goods.id}"><input id="radioback" class="optionsRadios2" type="radio" value="option2" name="optionsRadios"></a></td>
						<td>${inventory.goods.id}</td>
						<td>${inventory.goods.goodsname}</td>
						<td>${inventory.goods.productplace}</td>
						<td>${inventory.goods.size }</td>
						<td>${inventory.goods.pack }</td>
						<td>${inventory.goods.price }</td>
						<td>${inventory.number}</td>
						<td>${inventory.goods.productcode }</td>
						<td>${inventory.goods.provider.providername}</td>
					</tr>
				</c:forEach>
		 	</tbody>
		</table>
	</div>
	<script type="text/javascript">
		$(document).ready(function(){
			$(".optionsRadios2").click(function(){
				if($(this).attr("checked") == "checked"){
					$.get("getGoods"+$(this).parent().attr("rel"),function(goods){
						$("#backprovider").val(goods.provider.id);
						$("#backprovider").attr("readonly",true);
						$("#goodsbackId").val(goods.id);
						$("#goodsbackId").attr("readonly",true);
					});
				}
			});
			$("#btnback").click(function(){
				$.get("getGoodsBack",function(goodsBack){
					$("#backId").val(goodsBack.id);
					$("#backId").attr("readonly",true);
					$("#backTime").val(goodsBack.time);
					$("#backTime").attr("readonly",true);
					$("#backope").val(goodsBack.operator.id);
					$("#backope").attr("readonly",true);
				});
			});
			
		});
	
	</script>
  </body>
</html>
